<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>同源策略</title>
</head>
<body>
    <button id="btn">点击发送请求</button>
    <script>
        //访问该页面时, 需要启动 server.js 的服务, 
        // 然后通过 http://127.0.0.1/tong-yuan 查看效果


        //点击按钮 向 http://127.0.0.1/server 发送请求
        let btn = document.querySelector('#btn');

        btn.onclick = function(){
            let x = new XMLHttpRequest();
            x.open('get','http://127.0.0.1/server');
            x.send();
        }

    </script>
</body>
</html>